package com.john.blog.service.impl;

import java.util.List;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.john.blog.common.utils.DetectUtils;
import com.john.blog.model.mapper.NoticeMapper;
import com.john.blog.model.po.Notice;
import com.john.blog.service.NoticeService;

import tk.mybatis.mapper.entity.Example;

/**
 * 友情连接服务
 * 
 * @author JiangGengchao
 * @date 2018年2月4日
 */
@Service("noticeService")
public class NoticeServiceImpl extends BaseServiceImpl<Notice> implements NoticeService {

    @Autowired
    private NoticeMapper noticeMapper;

    @PostConstruct
    public void init() {
        this.mapper = noticeMapper;
    }

    @Override
    public List<Notice> findAll() {
        return this.noticeMapper.selectAll();
    }

    @Override
    public Notice selectByPrimaryKey(String id) {
        Example example = new Example(Notice.class);
        example.createCriteria().andEqualTo(Notice.ID, id);
        List<Notice> result = this.selectByExample(example);
        if (DetectUtils.notEmpty(result)) {
            return result.get(0);
        } else {
            return null;
        }
    }

}
